package pluginUtils;

import java.util.ArrayList;

public class DoyleCircleWithNeighbours extends DoyleCircle {
	
	private static int number=0; 
	private int myNumber; 
	
	private static ArrayList<DoyleCircleWithNeighbours> engendres=new ArrayList<DoyleCircleWithNeighbours>();
	
	public static void resetNumbers(){
		number=0;  
		engendres=new ArrayList<DoyleCircleWithNeighbours>(); 
	}
	
	private ArrayList<Integer> myNeighbours=new ArrayList<Integer>();
	
	public static DoyleCircleWithNeighbours makeCircle(double xcenter, double ycenter,
			double rotation, double radius, int ap, int bp) {
			DoyleCircleWithNeighbours cree=new DoyleCircleWithNeighbours(xcenter,ycenter,rotation,radius,ap,bp); 
			if(engendres.contains(cree)) return engendres.get(engendres.indexOf(cree)); 
			else {
				engendres.add(cree); 
				return cree; 
			}
		
	}
	
	public void getNeighbours(DoyleCircleWithNeighbours c){
		myNeighbours=new ArrayList<Integer>(c.myNeighbours); 
	}

	public DoyleCircleWithNeighbours(double xcenter, double ycenter,
			double rotation, double radius, int ap, int bp) {
		super(xcenter, ycenter, rotation, radius, ap, bp);
		this.myNumber=number++; 
	}

	public DoyleCircleWithNeighbours(Complexe z, double rotation,
			double radius, int ap, int bp) {
		super(z, rotation, radius, ap, bp);
		this.myNumber=number++; 
	}

	public DoyleCircleWithNeighbours(Circle c, double rotation, int ap, int bp) {
		super(c, rotation, ap, bp);
		this.myNumber=number++; 
	}
	
	public void addNeighbour(DoyleCircleWithNeighbours a){
		int u=a.myNumber; 
		if(!myNeighbours.contains(u)) this.myNeighbours.add(u); 
		if(!a.myNeighbours.contains(myNumber)) a.myNeighbours.add(myNumber); 
	}
	
	public String listNeighbours(){
		String s=""; 
		for(int u:myNeighbours) s+=u+" "; 
		return s; 
		}
	
	public int getNumberOfNeighbours(){ return this.myNeighbours.size(); }
	
	public int getNumber(){return this.myNumber; }
	
	public boolean equals(Object obj) {
		boolean resu=super.equals(obj); 
		if(resu){
			if(this!=obj)
			System.out.println("*** "+this.myNumber+" *** "+((DoyleCircleWithNeighbours)obj).myNumber); 
		}
		return resu;
	}
	

}
